<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
</html>

<script>
	var age = prompt("请输入您的年龄");
	if(isNaN(age)) prompt("请输入正确年龄");
	age = parseInt(age/10);
		switch (age){
		case 0:
			agename = "儿童";
			break;
		case 1:
			agename = "青少年";
			break;
		case 2:
		case 3:
			agename = "青年";
			break;
		case 4:
		case 6:
			agename = "中年";
			break;
		default:
		agename = "老年";
			break;
	}
	console.log(age,'age');
//	let agename ='';
//	switch (true){
//		case age<10:
//			agename = "儿童";
//			break;
//		case age>=10 && age <20:
//			agename = "青少年";
//			break;
//		case age>=20 && age <40:
//			agename = "青年";
//			break;
//		case age>=40 && age <60:
//			agename = "中年";
//			break;
//		default:
//		agename = "老年";
//			break;
//	}
	document.write(agename);
</script>